package com.bishe.demo.modules.tourism.controller;

import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.tourism.entity.RouteOrder;
import com.bishe.demo.modules.tourism.service.RouteOrderService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description RouteOrderController
 * @Author Lubb
 * @Date 2021/4/9 10:42
 */
@RequestMapping("/api")
@RestController
public class RouteOrderController {
    @Autowired
    private RouteOrderService routeOrderService;

    @PostMapping("/routeOrder")
    public ResultEntity<RouteOrder> addRouteOrder(@RequestBody RouteOrder routeOrder) {
        return routeOrderService.addRouteOrder(routeOrder);
    }

    @DeleteMapping("/routeOrder/{id}")
    public ResultEntity<RouteOrder> deleteRouteOrderById(@PathVariable Integer id) {
        return routeOrderService.deleteRouteOrderById(id);
    }

    @PutMapping("/routeOrder")
    public ResultEntity<RouteOrder> updateRouteOrderComment(@RequestBody RouteOrder routeOrder) {
        return routeOrderService.updateRouteOrderComment(routeOrder);
    }

    @GetMapping("/routeOrder/{userId}")
    public List<RouteOrder> getRouteOrderByUserId(@PathVariable Integer userId){
        return routeOrderService.getRouteOrderByUserId(userId);
    }
}
